package Exercise;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class DateBirthdayTest02 {

    public static void main(String[] args) throws ParseException {
        Date date = new Date();

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入两个yyyy-MM-DD格式的出生日期来让计算机来计算两个时间过了多少天多少天");
        while (true) {
        String res = scanner.next();
        String res1 = scanner.next();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-DD");
        Date birthday = simpleDateFormat.parse(res);
        Date birthdaytwo = simpleDateFormat.parse(res1);



            if (birthdaytwo.getTime() < birthday.getTime()) {
                System.out.println("相差" + ((birthdaytwo.getTime() - birthday.getTime()) / 1000 / 60 / 60 / 24) + "天");
                System.exit(0);

            } else {

                System.out.println("你输入的不正确,请重新输入");
            }
        }

    }
}
